<template>
  <div class="content" v-loading="isLoading">
    小组培训量统计。。。。待开发
    <!-- <div class="searchHead">
      <el-cascader
        v-model="exportCondition.groupId"
        placeholder="请选择培训组别"
        size="small"
        :options="groupTypeOptions"
        :props="{
          checkStrictly: true,
          value: 'groupId',
          label: 'groupName',
          emitPath: false,
        }"
      ></el-cascader>
      <el-cascader
        v-model="exportCondition.termType"
        placeholder="请选择导出学期"
        size="small"
        :options="termTypeOptions"
      ></el-cascader>
    </div> -->
  </div>
</template>
<script>
export default {
  components: {},
  data() {
    return {
      groupTypeOptions: [],
      termTypeOptions: [],
      exportCondition: {
        groupId: 10000,
        termType: "",
        startDate: "",
        endDate: "",
      },
    };
  },
  created() {
    this.getGroupType();
    this.getTermType();
  },
  mounted() {},
  methods: {
    /**
     * 获取学期信息表
     */
    async getTermType() {
      const res = await this.$axios.get(`${this.HOST}/record/api/term`);
      // console.log("term",res);
      if (res.data.meta.code == 200) {
        const terms = res.data.data.terms;
        console.log("获取学期信息成功！", terms);
        const termType = [];
        terms.forEach((ele) => {
          let termItem = {
            label: ele.schoolYear,
            children: [
              {
                value: [ele.superior, ele.down],
                label: "全学年",
              },
              {
                value: [ele.superior, ele.mid],
                label: "上学年",
              },
              {
                value: [ele.mid, ele.down],
                label: "下学年",
              },
            ],
          };
          termType.push(termItem);
        });
        this.termTypeOptions = termType;
        // console.log("termtype,", this.termTypeOptions);
      }
    },
    /**
     * 获取IT培优组别树
     */
    async getGroupType() {
      let gid = JSON.parse(window.sessionStorage.getItem("groupId"));
      if (gid == null) {
        this.queryInfo.groupId = [10000];
      } else {
        this.queryInfo.groupId = gid;
      }
      // console.log("gid",this.queryInfo.groupId);
      if (window.sessionStorage.getItem("groupTree") != null) {
        this.groupTypeOptions = JSON.parse(
          window.sessionStorage.getItem("groupTree")
        );
        console.log("已从本地获得GroupTree！", this.groupTypeOptions);
        return;
      }
      const res = await this.$axios.get(`${this.HOST}/group/api/groupTree`);
      if (res.data.meta.code == 200) {
        let arr = [];
        arr.push(res.data.data.groupTree);
        this.groupTypeOptions = arr;
        console.log("组别获取成功！", this.groupTypeOptions);
        window.sessionStorage.setItem(
          "groupTree",
          JSON.stringify(this.groupTypeOptions)
        );
        // console.log(this.queryInfo.groupId);
      } else if (res.status != 200) {
        this.$message({
          message: "获取失败！",
          type: "error",
        });
      }
    },
  },
};
</script>

<style lang="less" scoped>
.content {
  padding-left: 30px;
  padding-right: 30px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
</style>